//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.wsd.smartcarwasher.util;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class DateUtil {
    private static final Log log = LogFactory.getLog(DateUtil.class);
    public static String ymdhms = "yyyy-MM-dd HH:mm:ss";
    private static String ymd = "yyyy-MM-dd";
    public static SimpleDateFormat ymdSDF;
    private static String year;
    private static String month;
    private static String day;
    public static SimpleDateFormat yyyyMMddHHmmss;
    public static SimpleDateFormat yearSDF;
    public static SimpleDateFormat monthSDF;
    public static SimpleDateFormat daySDF;
    public static SimpleDateFormat yyyyMMddHHmm;
    public static SimpleDateFormat yyyyMMdd;
    public static SimpleDateFormat yyyyMMddHH_NOT_;
    public static long DATEMM;
    public static final String DATE_PATTERN = "yyyy-MM-dd";
    public static final String DATE = new Date().toLocaleString();
    public static String DATE_TIME_PATTERN_YYYY_MM_DD_HH_MM_SS_SSS;
    public static final String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
    public static String[][] regularExp;

    public DateUtil() {
    }

    public static String format(Date date) {
        return format(date, "yyyy-MM-dd");
    }

    public static String format(Date date, String pattern) {
        if (date != null) {
            SimpleDateFormat df = new SimpleDateFormat(pattern);
            return df.format(date);
        } else {
            return null;
        }
    }

    public static String timeToStr(Long time, String pattern) {
        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
        if (time.toString().length() < 13) {
            time = time * 1000L;
        }

        Date date = new Date(time);
        String value = dateFormat.format(date);
        return value;
    }

    public static long strToTime(String timeStr) {
        Date time = strToDate(timeStr);
        return time.getTime() / 1000L;
    }

    public static Date strToDate(String strDate) {
        try {
            String strType = getDateFormat(strDate);
            SimpleDateFormat sf = new SimpleDateFormat(strType);
            return new Date(sf.parse(strDate).getTime());
        } catch (Exception var3) {
            return null;
        }
    }

    public static String getDateFormat(String date_str) {
        String style = null;
        if (StringUtil.isEmpty(date_str)) {
            return null;
        } else {
            boolean b = false;

            for(int i = 0; i < regularExp.length; ++i) {
                b = date_str.matches(regularExp[i][0]);
                if (b) {
                    style = regularExp[i][1];
                }
            }

            if (StringUtil.isEmpty(style)) {
                log.info("date_str:" + date_str);
                log.info("日期格式获取出错，未识别的日期格式");
            }

            return style;
        }
    }

    public static Date convertStringToDate(String dateStr) {
        Date resultDate = null;

        try {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            resultDate = sdf.parse(dateStr);
        } catch (ParseException var3) {
            var3.printStackTrace();
        }

        return resultDate;
    }

    public static Date convertStringToHour(String dateStr) {
        Date resultDate = null;

        try {
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
            resultDate = sdf.parse(dateStr);
        } catch (ParseException var3) {
            var3.printStackTrace();
        }

        return resultDate;
    }













    public static String getCurrentTime() {
        return yyyyMMddHHmmss.format(new Date());
    }

    public static Date getSysTime() {
        return stringToDate(getCurrentTime(), ymdhms);
    }

    public static Date getSysDate() {
        return stringToDate(getCurrentTime(), ymd);
    }

    public static String getCurrentDate() {
        return ymdSDF.format(new Date());
    }

    public static String getYesterdayYYYYMMDD() {
        Date date = new Date(System.currentTimeMillis() - DATEMM * 1000L);
        String str = yyyyMMdd.format(date);

        try {
            date = yyyyMMddHHmmss.parse(str + " 00:00:00");
            return yyyyMMdd.format(date);
        } catch (ParseException var3) {
            var3.printStackTrace();
            return "";
        }
    }

    public static String getStrDate(int backDay) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(5, 0 - backDay);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String back = sdf.format(calendar.getTime());
        return back;
    }

    public static Date getDateBack(int backDay) {
        String backDate = getStrDate(backDay);
        return convertStringToDate(backDate);
    }

    public static Date getDateLater(Date date, int lateDay) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(5, lateDay);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return convertStringToDate(sdf.format(calendar.getTime()));
    }

    public static String getCurrentYear() {
        return yearSDF.format(new Date());
    }

    public static String getCurrentMonth() {
        return monthSDF.format(new Date());
    }

    public static String getCurrentDay() {
        return daySDF.format(new Date());
    }

    public static long getTimeNumberToday() {
        Date date = new Date();
        String str = yyyyMMdd.format(date);

        try {
            date = yyyyMMdd.parse(str);
            return date.getTime() / 1000L;
        } catch (ParseException var3) {
            var3.printStackTrace();
            return 0L;
        }
    }

    public static String getTodateString() {
        String str = yyyyMMddHH_NOT_.format(new Date());
        return str;
    }

    public static String getYesterdayString() {
        Date date = new Date(System.currentTimeMillis() - DATEMM * 1000L);
        String str = yyyyMMddHH_NOT_.format(date);
        return str;
    }

    public static Date getYesterDayZeroHour() {
        Calendar cal = Calendar.getInstance();
        cal.add(5, -1);
        cal.set(13, 0);
        cal.set(12, 0);
        cal.set(10, 0);
        return cal.getTime();
    }

    public static String longToString(long date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        Date dt2 = new Date(date * 1000L);
        String sDateTime = sdf.format(dt2);
        return sDateTime;
    }

    public static Date getTodayZeroHour() {
        Calendar cal = Calendar.getInstance();
        cal.set(13, 0);
        cal.set(12, 0);
        cal.set(10, 0);
        return cal.getTime();
    }

    public static Date getYesterDay24Hour() {
        Calendar cal = Calendar.getInstance();
        cal.add(5, -1);
        cal.set(13, 59);
        cal.set(12, 59);
        cal.set(10, 23);
        return cal.getTime();
    }

    public static Date stringToDate(String date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);

        try {
            return sdf.parse(date);
        } catch (ParseException var4) {
            return null;
        }
    }

    public static Date getStartDayOfWeek(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(7, 1);
        date = c.getTime();
        return date;
    }

    public static Date getLastDayOfWeek(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(7, 7);
        date = c.getTime();
        return date;
    }

    public static Date getStartDayOfMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(5, 1);
        date = c.getTime();
        return date;
    }

    public static Date getLastDayOfMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(5, 1);
        c.add(2, 1);
        c.add(5, -1);
        date = c.getTime();
        return date;
    }

    public static Date getStartDayOfNextMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(2, 1);
        c.set(5, 1);
        date = c.getTime();
        return date;
    }

    public static Date getLastDayOfNextMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(5, 1);
        c.add(2, 2);
        c.add(5, -1);
        date = c.getTime();
        return date;
    }

    public static String givedTimeToBefer(String givedTime, long interval, String format_Date_Sign) {
        String tomorrow = null;

        try {
            SimpleDateFormat sdf = new SimpleDateFormat(format_Date_Sign);
            Date gDate = sdf.parse(givedTime);
            long current = gDate.getTime();
            long beforeOrAfter = current - interval * 1000L;
            Date date = new Date(beforeOrAfter);
            tomorrow = (new SimpleDateFormat(format_Date_Sign)).format(date);
        } catch (ParseException var12) {
            var12.printStackTrace();
        }

        return tomorrow;
    }

    public static long stringToLong(String date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        Date dt2 = null;
        long lTime = 0L;

        try {
            dt2 = sdf.parse(date);
            lTime = dt2.getTime() / 1000L;
        } catch (ParseException var7) {
            var7.printStackTrace();
        }

        return lTime;
    }

    public static Map<String, String> getTwoDay(String endTime, String beginTime, boolean isEndTime) {
        Map<String, String> result = new HashMap();
        if (endTime != null && !endTime.equals("") && beginTime != null && !beginTime.equals("")) {
            try {
                Date date = ymdSDF.parse(endTime);
                endTime = ymdSDF.format(date);
                Date mydate = ymdSDF.parse(beginTime);
                long day = (date.getTime() - mydate.getTime()) / 86400000L;
                result = getDate(endTime, Integer.parseInt(day + ""), isEndTime);
            } catch (Exception var8) {
            }

            return (Map)result;
        } else {
            return null;
        }
    }

    public static Integer getTwoDayInterval(String endTime, String beginTime, boolean isEndTime) {
        if (endTime != null && !endTime.equals("") && beginTime != null && !beginTime.equals("")) {
            long day = 0L;

            try {
                Date date = ymdSDF.parse(endTime);
                endTime = ymdSDF.format(date);
                Date mydate = ymdSDF.parse(beginTime);
                day = (date.getTime() - mydate.getTime()) / 86400000L;
            } catch (Exception var7) {
                return 0;
            }

            return Integer.parseInt(day + "");
        } else {
            return 0;
        }
    }

    public static Map<String, String> getDate(String endTime, Integer interval, boolean isEndTime) {
        Map<String, String> result = new HashMap();
        if ((interval == 0 || isEndTime) && isEndTime) {
            result.put(endTime, endTime);
        }

        if (interval > 0) {
            int begin = 0;

            for(int i = begin; i < interval; ++i) {
                endTime = givedTimeToBefer(endTime, DATEMM, ymd);
                result.put(endTime, endTime);
            }
        }

        return result;
    }

    public static Date convertToGMT(Date date) {
        if (date == null) {
            return null;
        } else {
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            int zoneOffset = calendar.get(15);
            int dstOffset = calendar.get(16);
            calendar.add(14, -(dstOffset + zoneOffset));
            return calendar.getTime();
        }
    }

    static {
        ymdSDF = new SimpleDateFormat(ymd);
        year = "yyyy";
        month = "MM";
        day = "dd";
        yyyyMMddHHmmss = new SimpleDateFormat(ymdhms);
        yearSDF = new SimpleDateFormat(year);
        monthSDF = new SimpleDateFormat(month);
        daySDF = new SimpleDateFormat(day);
        yyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");
        yyyyMMddHH_NOT_ = new SimpleDateFormat("yyyyMMdd");
        DATEMM = 86400L;
        DATE_TIME_PATTERN_YYYY_MM_DD_HH_MM_SS_SSS = "yyyyMMddHHmmssSSS";
        regularExp = new String[][]{{"\\d{4}-((([0][1,3-9]|[1][0-2]|[1-9])-([0-2]\\d|[3][0,1]|[1-9]))|((02|2)-(([1-9])|[0-2]\\d)))\\s+([0,1]\\d|[2][0-3]|\\d):([0-5]\\d|\\d):([0-5]\\d|\\d)", "yyyy-MM-dd HH:mm:ss"}, {"\\d{4}-((([0][1,3-9]|[1][0-2]|[1-9])-([0-2]\\d|[3][0,1]|[1-9]))|((02|2)-(([1-9])|[0-2]\\d)))", "yyyy-MM-dd"}, {"\\d{4}((([0][1,3-9]|[1][0-2]|[1-9])([0-2]\\d|[3][0,1]|[1-9]))|((02|2)(([1-9])|[0-2]\\d)))([0,1]\\d|[2][0-3])([0-5]\\d|\\d)([0-5]\\d|\\d)\\d{1,3}", DATE_TIME_PATTERN_YYYY_MM_DD_HH_MM_SS_SSS}};
    }


    /**
     * 验证字符串时间，是否在30天内
     * @param str
     * @return
     */
    public static boolean isValidDate(String str) {
        boolean convertSuccess=true;
        //时间格式定义
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        //获取当前时间日期--nowDate
        String nowDate = format.format(new Date());
        //获取30天前的时间日期--minDate
        Calendar calc = Calendar.getInstance();
        calc.add(Calendar.DAY_OF_MONTH, -30);
        String minDate = format.format(calc.getTime());
        try {
            //设置lenient为false. 否则SimpleDateFormat会比较宽松地验证日期，比如2007/02/29会被接受，并转换成2007/03/01
            format.setLenient(false);
            //获取字符串转换后的时间--strDate
            String strDate = format.format(format.parse(str));
            //判断传的STR时间，是否在当前时间之前，且在30天日期之后-----测试的时候打印输出结果
//			System.out.println("nowDate.compareTo(strDate):"+ nowDate.compareTo(strDate));
//			System.out.println("strDate.compareTo(minDate):"+ strDate.compareTo(minDate));
            if (nowDate.compareTo(strDate) >= 0 && strDate.compareTo(minDate) >= 0){
                convertSuccess = true;
            }else{
                convertSuccess = false;
            }
        } catch (ParseException e) {
            convertSuccess=false;
        }
        return convertSuccess;
    }


    /**
     * 判断当前时间是否在[startTime, endTime]区间，注意时间格式要一致
     *
     * @param nowTime 当前时间
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return
     * @author jqlin
     */
    public static boolean isEffectiveDate(Date nowTime, Date startTime, Date endTime) {
        if (nowTime.getTime() == startTime.getTime()
                || nowTime.getTime() == endTime.getTime()) {
            return true;
        }

        Calendar date = Calendar.getInstance();
        date.setTime(nowTime);

        Calendar begin = Calendar.getInstance();
        begin.setTime(startTime);

        Calendar end = Calendar.getInstance();
        end.setTime(endTime);

        if (date.after(begin) && date.before(end)) {
            return true;
        } else {
            return false;
        }
    }




}


/*
package com.wsd.smartcarwasher.util;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;


*/
/**
 * 日期时间工具类
 *//*

public class DateUtil {

    private static final Log log = LogFactory.getLog(DateUtil.class);
    private static String ymdhms = "yyyy-MM-dd HH:mm:ss";
    private static String ymd = "yyyy-MM-dd";
    public static SimpleDateFormat ymdSDF = new SimpleDateFormat(ymd);
    private static String year = "yyyy";
    private static String month = "MM";
    private static String day = "dd";
    public static SimpleDateFormat yyyyMMddHHmmss = new SimpleDateFormat(ymdhms);
    public static SimpleDateFormat yearSDF = new SimpleDateFormat(year);
    public static SimpleDateFormat monthSDF = new SimpleDateFormat(month);
    public static SimpleDateFormat daySDF = new SimpleDateFormat(day);
    public static SimpleDateFormat yyyyMMddHHmm = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    public static SimpleDateFormat yyyyMMdd = new SimpleDateFormat("yyyy-MM-dd");
    public static SimpleDateFormat yyyyMMddHH_NOT_ = new SimpleDateFormat("yyyyMMdd");
    public static long DATEMM = 86400L;

    */
/**
     * 时间格式(yyyy-MM-dd)
     *//*

    public final static String DATE_PATTERN = "yyyy-MM-dd";
    */
/**
     * 无分隔符日期格式 "yyyyMMddHHmmssSSS"
     *//*

    public static String DATE_TIME_PATTERN_YYYY_MM_DD_HH_MM_SS_SSS = "yyyyMMddHHmmssSSS";
    */
/**
     * 时间格式(yyyy-MM-dd HH:mm:ss)
     *//*

    public final static String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";

    // 日期转换格式数组
    public static String[][] regularExp = new String[][]{

            // 默认格式
            {"\\d{4}-((([0][1,3-9]|[1][0-2]|[1-9])-([0-2]\\d|[3][0,1]|[1-9]))|((02|2)-(([1-9])|[0-2]\\d)))\\s+([0,1]\\d|[2][0-3]|\\d):([0-5]\\d|\\d):([0-5]\\d|\\d)",
                    DATE_TIME_PATTERN},
            // 仅日期格式 年月日
            {"\\d{4}-((([0][1,3-9]|[1][0-2]|[1-9])-([0-2]\\d|[3][0,1]|[1-9]))|((02|2)-(([1-9])|[0-2]\\d)))",
                    DATE_PATTERN},
            //  带毫秒格式
            {"\\d{4}((([0][1,3-9]|[1][0-2]|[1-9])([0-2]\\d|[3][0,1]|[1-9]))|((02|2)(([1-9])|[0-2]\\d)))([0,1]\\d|[2][0-3])([0-5]\\d|\\d)([0-5]\\d|\\d)\\d{1,3}",
                    DATE_TIME_PATTERN_YYYY_MM_DD_HH_MM_SS_SSS}
    };

    public static String format(Date date) {
        return format(date, DATE_PATTERN);
    }

    public static String format(Date date, String pattern) {
        if (date != null) {
            SimpleDateFormat df = new SimpleDateFormat(pattern);
            return df.format(date);
        }
        return null;
    }

    public static String timeToStr(Long time, String pattern) {
        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
        if (time.toString().length() < 13) {
            time = time * 1000L;
        }
        Date date = new Date(time);
        String value = dateFormat.format(date);
        return value;
    }

    public static long strToTime(String timeStr) {
        Date time = strToDate(timeStr);
        return time.getTime() / 1000;
    }


    */
/**
     * 转换为时间类型格式
     *
     * @param strDate 日期
     * @return
     *//*

    public static Date strToDate(String strDate) {
        try {
            String strType = getDateFormat(strDate);
            SimpleDateFormat sf = new SimpleDateFormat(strType);
            return new Date((sf.parse(strDate).getTime()));
        } catch (Exception e) {
            return null;
        }
    }


    */
/**
     * 根据传入的日期格式字符串，获取日期的格式
     *
     * @return 秒
     *//*

    public static String getDateFormat(String date_str) {
        String style = null;
        if (StringUtil.isEmpty(date_str)) {
            return null;
        }
        boolean b = false;
        for (int i = 0; i < regularExp.length; i++) {
            b = date_str.matches(regularExp[i][0]);
            if (b) {
                style = regularExp[i][1];
            }
        }
        if (StringUtil.isEmpty(style)) {
            log.info("date_str:" + date_str);
            log.info("日期格式获取出错，未识别的日期格式");
        }
        return style;
    }

    */
/**
     * 将字符串类型的转换成Date类型
     *
     * @param dateStr
     *            字符串类型的日期 yyyy-MM-dd
     * @return Date类型的日期
     * @throws ParseException
     *//*

    public static Date convertStringToDate(String dateStr) {
        // 返回的日期
        Date resultDate = null;
        try {
            // 日期格式转换
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            resultDate = sdf.parse(dateStr);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return resultDate;
    }

    */
/**
     * 获得当前时间(字符串类型)
     * 格式：2014-12-02 10:38:53
     * @return String
     *//*

    public static String getCurrentTime() {
        return yyyyMMddHHmmss.format(new Date());
    }
    */
/**
     * 获得当前时间(日期类型)
     * 格式：2014-12-02 10:38:53
     * @return String
     *//*

    public static Date getSysTime() {
        return DateUtil.stringToDate(getCurrentTime(), ymdhms);
    }

    */
/**
     * 获取年月日(日期类型)
     * 格式：2014-12-02
     * @return String
     *//*

    public static Date getSysDate() {
        return DateUtil.stringToDate(getCurrentTime(), ymd);
    }

    */
/**
     * 获取年月日(字符串类型)
     * 格式：2014-12-02
     * @return String
     *//*

    public static String getCurrentDate() {
        return ymdSDF.format(new Date());
    }

    */
/**
     * 可以获取昨天的日期
     * 格式：2014-12-01
     *
     * @return String
     *//*

    public static String getYesterdayYYYYMMDD() {
        Date date = new Date(System.currentTimeMillis() - DATEMM * 1000L);
        String str = yyyyMMdd.format(date);
        try {
            date = yyyyMMddHHmmss.parse(str + " 00:00:00");
            return yyyyMMdd.format(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return "";
    }

    */
/**
     * 可以获取后退N天的日期
     * 格式：传入2 得到2014-11-30
     * @param backDay
     * @return String
     *//*

    public static String getStrDate(String backDay) {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.DATE, Integer.parseInt("-" + backDay));
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String back = sdf.format(calendar.getTime());
        return back;
    }

    public static Date getDateBack(String backDay) {
        String backDate = getStrDate(backDay);
        return convertStringToDate(backDate);
    }

    public static Date getDateLater(Date date, int lateDay) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.DATE, lateDay);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return convertStringToDate(sdf.format(calendar.getTime()));
    }

    */
/**
     * 获取当前的年、月、日
     * @return String
     *//*

    public static String getCurrentYear() {
        return yearSDF.format(new Date());
    }

    public static String getCurrentMonth() {
        return monthSDF.format(new Date());
    }

    public static String getCurrentDay() {
        return daySDF.format(new Date());
    }

    */
/**
     * 获取今天0点开始的秒数
     * @return long
     *//*

    public static long getTimeNumberToday() {
        Date date = new Date();
        String str = yyyyMMdd.format(date);
        try {
            date = yyyyMMdd.parse(str);
            return date.getTime() / 1000L;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return 0L;
    }

    */
/**
     * 获取今天的日期
     * 格式：20141202
     * @return String
     *//*

    public static String getTodateString() {
        String str = yyyyMMddHH_NOT_.format(new Date());
        return str;
    }

    */
/**
     * 获取昨天的日期
     * 格式：20141201
     * @return String
     *//*

    public static String getYesterdayString() {
        Date date = new Date(System.currentTimeMillis() - DATEMM * 1000L);
        String str = yyyyMMddHH_NOT_.format(date);
        return str;
    }

    */
/**
     * 获得昨天零点
     * @return Date
     *//*

    public static Date getYesterDayZeroHour() {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, -1);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.HOUR, 0);
        return cal.getTime();
    }

    */
/**
     * 把long型日期转String ；---OK
     * @param date   long型日期；
     * @param format 日期格式；
     * @return
     *//*

    public static String longToString(long date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        // 前面的lSysTime是秒数，先乘1000得到毫秒数，再转为java.util.Date类型
        java.util.Date dt2 = new Date(date * 1000L);
        String sDateTime = sdf.format(dt2); // 得到精确到秒的表示：08/31/2006 21:08:00
        return sDateTime;
    }

    */
/**
     * 获得今天零点
     * @return Date
     *//*

    public static Date getTodayZeroHour() {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.HOUR, 0);
        return cal.getTime();
    }

    */
/**
     * 获得昨天23时59分59秒
     * @return
     *//*

    public static Date getYesterDay24Hour() {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, -1);
        cal.set(Calendar.SECOND, 59);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.HOUR, 23);
        return cal.getTime();
    }

    */
/**
     * String To Date ---OK
     * @param date   待转换的字符串型日期；
     * @param format 转化的日期格式
     * @return 返回该字符串的日期型数据；
     *//*

    public static Date stringToDate(String date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        try {
            return sdf.parse(date);
        } catch (ParseException e) {
            return null;
        }
    }

    */
/**
     * 获得指定日期所在的自然周的第一天，即周日
     * @param date 日期
     * @return 自然周的第一天
     *//*

    public static Date getStartDayOfWeek(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.DAY_OF_WEEK, 1);
        date = c.getTime();
        return date;
    }

    */
/**
     * 获得指定日期所在的自然周的最后一天，即周六
     * @param date
     * @return
     *//*

    public static Date getLastDayOfWeek(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.DAY_OF_WEEK, 7);
        date = c.getTime();
        return date;
    }

    */
/**
     * 获得指定日期所在当月第一天
     * @param date
     * @return
     *//*

    public static Date getStartDayOfMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.DAY_OF_MONTH, 1);
        date = c.getTime();
        return date;
    }

    */
/**
     * 获得指定日期所在当月最后一天
     * @param date
     * @return
     *//*

    public static Date getLastDayOfMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.DATE, 1);
        c.add(Calendar.MONTH, 1);
        c.add(Calendar.DATE, -1);
        date = c.getTime();
        return date;
    }

    */
/**
     * 获得指定日期的下一个月的第一天
     * @param date
     * @return
     *//*

    public static Date getStartDayOfNextMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.MONTH, 1);
        c.set(Calendar.DAY_OF_MONTH, 1);
        date = c.getTime();
        return date;
    }

    */
/**
     * 获得指定日期的下一个月的最后一天
     * @param date
     * @return
     *//*

    public static Date getLastDayOfNextMonth(Date date) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.set(Calendar.DATE, 1);
        c.add(Calendar.MONTH, 2);
        c.add(Calendar.DATE, -1);
        date = c.getTime();
        return date;
    }

    */
/**
     * 求某一个时间向前多少秒的时间(currentTimeToBefer)---OK
     * @param givedTime        给定的时间
     * @param interval         间隔时间的毫秒数；计算方式 ：n(天)*24(小时)*60(分钟)*60(秒)(类型)
     * @param format_Date_Sign 输出日期的格式；如yyyy-MM-dd、yyyyMMdd等；
     *//*

    public static String givedTimeToBefer(String givedTime, long interval, String format_Date_Sign) {
        String tomorrow = null;
        try {
            SimpleDateFormat sdf = new SimpleDateFormat(format_Date_Sign);
            Date gDate = sdf.parse(givedTime);
            long current = gDate.getTime(); // 将Calendar表示的时间转换成毫秒
            long beforeOrAfter = current - interval * 1000L; // 将Calendar表示的时间转换成毫秒
            Date date = new Date(beforeOrAfter); // 用timeTwo作参数构造date2
            tomorrow = new SimpleDateFormat(format_Date_Sign).format(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return tomorrow;
    }

    */
/**
     * 把String 日期转换成long型日期；---OK
     *
     * @param date   String 型日期；
     * @param format 日期格式；
     * @return
     *//*

    public static long stringToLong(String date, String format) {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        Date dt2 = null;
        long lTime = 0;
        try {
            dt2 = sdf.parse(date);
            // 继续转换得到秒数的long型
            lTime = dt2.getTime() / 1000;
        } catch (ParseException e) {
            e.printStackTrace();
        }

        return lTime;
    }

    */
/**
     * 得到二个日期间的间隔日期；
     *
     * @param endTime   结束时间
     * @param beginTime 开始时间
     * @param isEndTime 是否包含结束日期；
     * @return
     *//*

    public static Map<String, String> getTwoDay(String endTime,
                                                String beginTime, boolean isEndTime) {
        Map<String, String> result = new HashMap<String, String>();
        if ((endTime == null || endTime.equals("") || (beginTime == null || beginTime
                .equals(""))))
            return null;
        try {
            java.util.Date date = ymdSDF.parse(endTime);
            endTime = ymdSDF.format(date);
            java.util.Date mydate = ymdSDF.parse(beginTime);
            long day = (date.getTime() - mydate.getTime())
                    / (24 * 60 * 60 * 1000);
            result = getDate(endTime, Integer.parseInt(day + ""), isEndTime);
        } catch (Exception e) {
        }
        return result;
    }

    */
/**
     * 得到二个日期间的间隔日期；
     *
     * @param endTime   结束时间
     * @param beginTime 开始时间
     * @param isEndTime 是否包含结束日期；
     * @return
     *//*

    public static Integer getTwoDayInterval(String endTime, String beginTime,
                                            boolean isEndTime) {
        if ((endTime == null || endTime.equals("") || (beginTime == null || beginTime
                .equals(""))))
            return 0;
        long day = 0l;
        try {
            java.util.Date date = ymdSDF.parse(endTime);
            endTime = ymdSDF.format(date);
            java.util.Date mydate = ymdSDF.parse(beginTime);
            day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
        } catch (Exception e) {
            return 0;
        }
        return Integer.parseInt(day + "");
    }

    */
/**
     * 根据结束时间以及间隔差值，求符合要求的日期集合；
     *
     * @param endTime
     * @param interval
     * @param isEndTime
     * @return
     *//*

    public static Map<String, String> getDate(String endTime, Integer interval,
                                              boolean isEndTime) {
        Map<String, String> result = new HashMap<String, String>();
        if (interval == 0 || isEndTime) {
            if (isEndTime)
                result.put(endTime, endTime);
        }
        if (interval > 0) {
            int begin = 0;
            for (int i = begin; i < interval; i++) {
                endTime = givedTimeToBefer(endTime, DATEMM, ymd);
                result.put(endTime, endTime);
            }
        }
        return result;
    }
}
*/


